Skip to content

Support the new Slack data visualization block (line, bar, area, pie)#91

Merged
StephenTangCook merged 4 commits into
mainfrom
claude/wizardly-turing-k9ucct
Jun 24, 2026
Merged

Support the new Slack data visualization block (line, bar, area, pie)#91
StephenTangCook merged 4 commits into
mainfrom
claude/wizardly-turing-k9ucct

Conversation

@StephenTangCook

@StephenTangCook StephenTangCook commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds support for Slack's new data_visualization Block Kit block, introduced in the 2026-06-16 Block Kit release (block reference). The block renders data as line, bar, area, or pie charts.

Slack draws these with ECharts → SVG. To stay consistent with the rest of this library (alert / card / carousel are all hand-rolled), the renderer uses dependency-free inline SVG — no charting library is added.

What's included

  • TypesDataVisualizationBlock plus DataVizChart (cartesian line / bar / area via series + axis_config, and pie via segments), added to the Block union and exported for consumers.
  • Renderer — an inline-SVG chart component handling:
    • multi-series line, grouped bar, and filled area charts, with smooth monotone-cubic curves for line/area (no overshoot, safe for negatives)
    • negative values anchored to a zero baseline
    • "nice" auto-scaled Y-axis ticks, gridlines, axis titles, and category labels
    • a color-swatch legend using Slack's palette
    • pie charts with proportional slices and a percentage legend
    • Slack's accessible aria-label patterns (e.g. "Line chart: … There are 2 series: Desktop and Mobile.", "Pie chart: …, with 4 segments. Segments: Free (52%), …")
    • light & dark mode
  • Interactions — hover tooltips on every chart, a dashed category guide on line/bar (with per-series value markers), and pie-slice expand-on-hover. All client-side and SSR-safe — the default server render is unchanged.
  • Affordances — a "view as table" toggle and a CSV download, mirroring Slack's chart action buttons (both SSR-safe).
  • Docs — completes the readme Supported Blocks table: adds the new block, plus the previously-missing Alert / Card / Carousel rows and a note on the Header block's level (H1–H4) support.
  • Playground — a "Data visualization · charts" fixture covering all four chart types.
  • Teststest/data_visualization.test.mjs renders the Block Kit example payloads and locks in the <h3> title, aria-labels, legend, axis labels, negative-value handling, pie percentages, and the smooth-curve paths.

Validation

Ran the full CI sequence locally against the lockfile-pinned deps: lint (tsc) clean → build succeeds → 16/16 tests pass.

Notes

  • No new runtime dependencies.
  • The block-kit-builder debug link works automatically — the sanitizer passes unknown block types through unchanged.
  • Pie percentages are rounded to integers (matching Slack's display).

https://claude.ai/code/session_018T7Lik8eFCV8DMtTckZC6a


Generated by Claude Code

claude added 2 commits June 16, 2026 18:16
…arts)

Adds the new Slack data_visualization Block Kit block introduced in the
2026-06-16 Block Kit release.

- Types: DataVisualizationBlock plus DataVizChart (cartesian line/bar/area
  via series + axis_config, and pie via segments) added to the Block union.
- Renderer: a dependency-free inline-SVG chart component covering line,
  grouped bar, stacked-style area, and pie. Handles multi-series, negative
  values (zero baseline), "nice" auto-scaled Y ticks, axis/category labels,
  a color-swatch legend, and Slack's accessible aria-label patterns. Works
  in both light and dark mode.
- Affordances: a "view as table" toggle and a CSV download, mirroring
  Slack's chart action buttons (SSR-safe).
- Docs/playground: readme Supported Blocks row and a charts fixture.
- Tests: renders the Block Kit example fixtures and locks in the h3 title,
  aria-labels, legend, axis labels, negative handling, and pie percentages.

https://claude.ai/code/session_018T7Lik8eFCV8DMtTckZC6a
Add the Alert, Card, and Carousel rows that were missing from the readme,
note the Header block's `level` (H1–H4) support, and realign the table now
that "Data Visualization" is the widest block name.

https://claude.ai/code/session_018T7Lik8eFCV8DMtTckZC6a
@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for the PR, @StephenTangCook!

You can try these changes live, before any release — no install needed.
Once the preview build finishes (see the pkg-pr-new bot comment), open the playground and load this PR's build:

🛝 Playground: https://slack-block-to-jsx-playground.vercel.app/
📦 This PR's build: https://pkg.pr.new/slack-blocks-to-jsx@91

Paste the build URL into the Library package field (or hit the pkg.pr #91 preset) and click Load build — your blocks render against this exact PR. 🎉

@pkg-pr-new

pkg-pr-new Bot commented Jun 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/slack-blocks-to-jsx@91

commit: 9f2af7f

@StephenTangCook

Copy link
Copy Markdown
Collaborator Author

@themashcodee I'm loving the preview feature. Could we make it even easier by making the library package a configurable query param?? :) Then this PR comment could give you a one-click preview URL.

- Line and area charts now use monotone-cubic (Fritsch–Carlson) interpolation
  for smooth curves that never overshoot the data (safe for negatives).
- Hover behavior matching Slack:
  - line/bar show a tooltip with the category and every series value, plus a
    dashed vertical guide at the nearest category; line/area also mark each
    series' value at that point.
  - pie shows a tooltip for the hovered segment, and the slice expands outward
    from the pie center.
- All interactivity is client-side and SSR-safe (default render is unchanged).

https://claude.ai/code/session_018T7Lik8eFCV8DMtTckZC6a
@StephenTangCook StephenTangCook force-pushed the claude/wizardly-turing-k9ucct branch from e31d020 to 4e2e246 Compare June 16, 2026 19:01
…eadme types

Review follow-ups:
- Memoize CartesianChart's hover-independent geometry (domain, ticks, scales,
  and the monotone-cubic path strings) with useMemo keyed on [model, type], so
  pointer-move re-renders no longer rebuild the spline paths.
- Extract a shared SeriesStroke component; the line and area branches no longer
  duplicate the identical stroked-path markup.
- readme: list the remaining exported block types (Table, Alert, Card, Carousel,
  Data Visualization) in the TypeScript example.

https://claude.ai/code/session_018T7Lik8eFCV8DMtTckZC6a
@StephenTangCook StephenTangCook merged commit a8bf4be into main Jun 24, 2026
4 checks passed
@StephenTangCook StephenTangCook deleted the claude/wizardly-turing-k9ucct branch June 24, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants